package top.songxs.gmall.common.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import top.songxs.gmall.cart.vo.UserAuthInfoVo;

import javax.servlet.http.HttpServletRequest;

public class UserAuthUtil {
    public static UserAuthInfoVo getUserAuthInfo(){
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
        if (requestAttributes!=null){
            HttpServletRequest request = requestAttributes.getRequest();
            String userId = request.getHeader("userId");
            String userTempId = request.getHeader("userTempId");
            UserAuthInfoVo userAuthInfoVo = new UserAuthInfoVo();
            userAuthInfoVo.setUserId(userId);
            userAuthInfoVo.setUserTempId(userTempId);

            return userAuthInfoVo;
        }

        return null;
    }

}
